package com.nanbei.rabbit.producer.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassDescription:
 * @JdkVersion: 1.8
 * @Author: libs
 * @Created: 2024/8/28 16:16
 */
@Configuration
public class RabbitTopicExchangeConfig {
    // 交换机  durable 持久化
    @Bean
    public Exchange topicExchange(){
        return ExchangeBuilder.topicExchange("topic_exchange").durable(true).build();
    }

    // 队列
    @Bean
    public Queue topicQueue01(){
        return QueueBuilder.durable("topic_queue_01").build();
    }

    @Bean
    public Queue topicQueue02(){
        return QueueBuilder.durable("topic_queue_02").build();
    }

    // 交换机绑定队列
    @Bean
    public Binding topicExchangeBindingQueue01(){
        return BindingBuilder.bind(topicQueue01()).to(topicExchange()).with("*.topic.*").noargs();
    }

    @Bean
    public Binding topicExchangeBindingQueue02BinInfo(){
        return BindingBuilder.bind(topicQueue02()).to(topicExchange()).with("topic.#").noargs();
    }

}
